; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win9x / NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;	Template AutoIt script.
;
; ----------------------------------------------------------------------------


; ----------------------------------------------------------------------------
; Set up our defaults
; ----------------------------------------------------------------------------

;AutoItSetOption("MustDeclareVars", 1)
;AutoItSetOption("MouseCoordMode", 0)
;AutoItSetOption("PixelCoordMode", 0)
;AutoItSetOption("RunErrorsFatal", 0)
;AutoItSetOption("TrayIconDebug", 1)
;AutoItSetOption("WinTitleMatchMode", 4)


; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

FileCopy ( "d:\tools\spilot_set\network", "c:\windows\system32\z\network",1)

$hostnamefile = FileOpen("c:\windows\system32\z\hostname", 0)
	; Check if file opened for reading OK
	If $hostnamefile = -1 Then
    		MsgBox(0, "Error", "Unable to open file c:\windows\system32\z\hostname.")
    		Exit
	EndIf
	$num = FileReadLine($hostnamefile)
	FileClose($hostnamefile)
sleep(300)
If $num >= 1 AND $num <= 137 Then 
	$computername 	= "SPILOT-"&$num
	$ipnum		= $num+10
	$ipaddress	= "192.168.1."&$ipnum
	$netmask	= "255.255.255.0"
	$gateway	= "192.168.1.1"
	$dns		= "202.100.64.68,202.100.64.66"
EndIf

If $num >137 Then
	$computername   = "SPILOT-"&$num
	$ipnum		= $num-90
	$ipaddress	= "192.168.2."&$ipnum
	$netmask	= "255.255.255.0"
	$gateway	= "192.168.2.1"
	$dns		= "202.100.64.68,202.100.64.66"
EndIf

;MsgBox(0,"hostname",$computername)
;MsgBox(0,"ipaddress",$ipaddress)
;MsgBox(0,"netmask",$netmask)
;MsgBox(0,"gateway",$gateway)
;MsgBox(0,"dns",$dns)

$networkfile = FileOpen("c:\windows\system32\z\network", 1)
	; Check if file opened for writing OK
	If $networkfile = -1 Then
    		MsgBox(0, "Error", "Unable to open file c:\windows\system32\z\network.")
    		Exit
	EndIf	

FileWriteLine ( $networkfile, $computername )
FileWriteLine ( $networkfile, $ipaddress )
FileWriteLine ( $networkfile, $netmask )
FileWriteLine ( $networkfile, $gateway )
FileWriteLine ( $networkfile, $dns )


FileClose($networkfile)
	